
<?php
$this->headLink()->appendStylesheet($this->baseUrl() . '/public/styles/datepicker/jquery.datepick.css');
$this->headScript()->prependFile($this->baseUrl() . '/public/scripts/datepicker/jquery.datepick.js');
?>

<article class="module width_full">
    <header><h3>Modificar Tarea</h3></header>
    <div class="module_content">
        <form style="width: 600px;" class="cmxform" method="post" id="addTareaForm" action="<?php echo $this->url(); ?>">
            <p>
                <label for="title">Titulo *</label>
                <input name="title" id="title" value="<?php echo $this->tarea->title ?>"/>
            </p>
            <p>
                <label for="description">Detalle</label>
                <textarea name="description" id="description"><?php echo $this->tarea->description ?></textarea>
            </p>

            <p>
                <label for="id_user">Para la Orden</label>
                <select id="id_orden" name="id_orden">
                    <option>-- Seleccione una Orden --</option>
                    <?php foreach ($this->resultOrden as $orden) : ?>
                        <option value="<?php echo $orden->id; ?>" <?php echo ($orden->id == $this->tarea->id_orden) ? 'selected="selected"' : ''; ?> >
                            <?php echo $orden->code . ' - ' . $orden->title; ?>
                        </option>
                    <?php endforeach; ?>
                </select>
            </p>
            <p>
                <label for="id_job">Trabajo</label>
                <select name="id_job" id="id_job">
                    <option value="0">--seleccione el trabajo--</option>
                    <?php foreach ($this->resultJob as $value) : ?>
                        <option value="<?php echo $value->id ?>" <?php echo ($value->id == $this->tarea->id_job) ? 'selected="selected"' : ''; ?>><?php echo $value->name ?></option>
                    <?php endforeach; ?>
                </select>
            </p>
            <p>
                <label for="id_user">Usuario Asignado</label>
            </p>
            <article class="stats_overview" style="float: left; width: 450px;">
                <div class="overview_today" style="width: 200px; float: left">
                    <?php foreach ($this->resultUserSupervisores as $usersup) : ?>
                        <p style="text-align: left;">
                            <?php
                            foreach ($this->usersTarea as $userTarea) {
                                if ($userTarea->id_user == $usersup->id) {
                                    $checked = 'checked="checked"';
                                    break;
                                } else {
                                    $checked = '';
                                }
                            }
                            ?>
                            <input type="checkbox" class="checkbox" name="checkUser[]" id="checkUser" value="<?php echo $usersup->id ?>" <?php echo $checked ?>/>
                            <?php echo $usersup->nombre . ' ' . $usersup->apellidos ?>
                        </p>
                    <?php endforeach; ?>
                </div>
                <div class="overview_previous" style="width: 200px; float: left">
                    <?php foreach ($this->resultUserDesignerDeveloper as $userd) : ?>
                        <p style="text-align: left;">
                            <?php
                            foreach ($this->usersTarea as $userTarea) {
                                if ($userTarea->id_user == $userd->id) {
                                    $checked = 'checked="checked"';
                                    break;
                                } else {
                                    $checked = '';
                                }
                            }
                            ?>
                            <input type="checkbox" class="checkbox" name="checkUser[]" id="checkUser" value="<?php echo $userd->id ?>" <?php echo $checked ?>/>
                            <?php echo $userd->nombre . ' ' . $userd->apellidos ?>
                        </p>
                    <?php endforeach; ?>
                </div>
            </article>
            <div class="clear"></div>

            <div class="submit_link" style="margin-top: 10px;">
                <input type="submit" value="Guardar" class="alt_btn"/>
                <a class="button" href="<?php echo $this->url(array('action' => 'view')) ?>">Cerrar</a>
            </div>
        </form>    
    </div>
    <footer></footer>
</article>


<div style="display: none;">
    <img id="calImg" src="<?php echo $this->baseUrl() . '/public/img/calendar-blue.gif' ?>" alt="Popup" class="trigger">
</div>

<script>
    $(function() {
        $('#create_date, #end_date').datepick({
            showOnFocus: false, 
            showTrigger: '#calImg',
            dateFormat: 'dd-mm-yyyy'
        });
        
        $('#finalizar').css({
            'margin-top': '-41px',
            'margin-left': '90px',
            'display': 'table'
        });
        $('#finalizar').click(function(e){
            e.preventDefault();
            location.href = '<?php echo $this->url(array('module' => 'tarea', 'controller' => 'index', 'action' => 'view'), null, true) ?>';
            return false;
        })
    });
</script>